<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>变颜色</title>
    <style>
        .container{
            border: 5px solid black;
            height: 300px;
        }

        @media screen and (min-width:1024px) {
            .container{
                background: chartreuse;
            }
        }

        @media screen and (min-width:640px) and (max-width: 1023px) {
            .container{
                background: crimson;
            }
        }

        @media screen and (min-width:320px) and (max-width: 639px) {
            .container{
                background: darkgoldenrod;
            }
        }
    </style>
</head>
<body>
    <div class="container"></div>
</body>
</html>